
 

#import "MB_PersonalTableViewCell.h"

@implementation MB_PersonalTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.titleLabel = ({
            UILabel *label = [[UILabel alloc]init];
            label.textColor = rgba(90, 90, 90, 1);
            label.font = FontPFRegular(kRWidth(15));
            label.text = @"";
            [self.contentView addSubview:label];
            label;
        });
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_offset(kRHeight(20));
            make.left.mas_offset(kRWidth(19));
            make.height.mas_equalTo(kRHeight(20));
        }];
        //
        self.textField = [[UITextField alloc]init];
        self.textField.textColor = [UIColor lightGrayColor];
        self.textField.font = FontPFRegular(kRWidth(15));
        self.textField.placeholder = @"请输入";
        self.textField.textAlignment = NSTextAlignmentRight;
        self.textField.text = @"";
        [self.textField addTarget:self action:@selector(Onclick:) forControlEvents:UIControlEventEditingChanged];
        [self.contentView addSubview:self.textField];
        [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.textField);
            make.left.mas_equalTo(self.titleLabel.mas_right).offset(kRWidth(20));
            make.right.mas_offset(-kRWidth(12));
            make.height.mas_equalTo(kRHeight(40));
        }];
        
    }
    return self;
}
//
- (void)Onclick:(UITextField*)obj {
    if ([self.delegate respondsToSelector:@selector(sendCelltext:index:)]) {
        [self.delegate sendCelltext:obj.text index:_index];
    }
}
//
- (void)setModel:(PersonalData *)model {
    
    NSLog(@"===%@==%@==%@",model.nickname,model.interests,model.motto);
    switch (_index) {
        case 0:
            self.textField.text = model.nickname;
            break;
        case 2:
            self.textField.text = model.interests;
            break;
        case 3:
            self.textField.text = model.motto;
            break;
            
        default:
            break;
    }
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
